class Solution:
    def longestPalindrome(self, s: str) -> str:
        def find(tmpStr, l, r):
            while l >= 0 and r < len(tmpStr) and tmpStr[l] == tmpStr[r]:
                l -= 1
                r += 1
            return tmpStr[l + 1: r]

        ans = None
        ansLen = 0
        for i in range(len(s)):
            tmp1 = find(s, i, i)
            tmp2 = find(s, i, i + 1)
            cur = tmp1 if len(tmp1) > len(tmp2) else tmp2
            if len(cur) > ansLen:
                ansLen = len(cur)
                ans = cur
        return ans


if __name__ == "__main__":
    s = Solution()
    print(s.longestPalindrome("a"))
